[HVM] Save/restore: don't get guest size from "memory_static_min"
authorTim Deegan <Tim.Deegan@xensource.com>
Thu, 29 Mar 2007 15:27:18 +0000 (15:27 +0000)
committerTim Deegan <Tim.Deegan@xensource.com>
Thu, 29 Mar 2007 15:27:18 +0000 (15:27 +0000)
since it doesn't mean that any more.  This is a sticking-plaster
to get HVM S/R working until the proper memory-map handling patch
is ready.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
tools/libxc/xc_hvm_restore.c
tools/python/xen/xend/XendCheckpoint.py
tools/xcutils/xc_restore.c

index 4b54b0aaf50be2b4de5ee2da062d5cb860210ef4..32fa627005372b213adae852a1ae2629b8fb2d46 100644 (file)
@@ -81,7 +81,7 @@ int xc_hvm_restore(int xc_handle, int io_fd,
     unsigned int rc = 1, n, i;
     uint32_t rec_len, nr_vcpus;
     uint8_t *hvm_buf = NULL;
-    unsigned long long v_end, memsize;
+    unsigned long long v_end;
     unsigned long shared_page_nr;
 
     unsigned long pfn;
@@ -91,16 +91,19 @@ int xc_hvm_restore(int xc_handle, int io_fd,
     /* Types of the pfns in the current region */
     unsigned long region_pfn_type[MAX_BATCH_SIZE];
 
-    /* Number of pages of memory the guest has.  *Not* the same as max_pfn. */
-    unsigned long nr_pages;
-
     /* The size of an array big enough to contain all guest pfns */
     unsigned long pfn_array_size = max_pfn + 1;
 
-    /* hvm guest mem size (Mb) */
-    memsize = (unsigned long long)*store_mfn;
-    v_end = memsize << 20;
-    nr_pages = (unsigned long) memsize << (20 - PAGE_SHIFT);
+    /* Number of pages of memory the guest has.  *Not* the same as max_pfn. */
+    unsigned long nr_pages = max_pfn + 1;
+    /* MMIO hole doesn't contain RAM */
+    if ( nr_pages >= HVM_BELOW_4G_MMIO_START >> PAGE_SHIFT ) 
+        nr_pages -= HVM_BELOW_4G_MMIO_LENGTH >> PAGE_SHIFT; 
+    /* VGA hole doesn't contain RAM */
+    nr_pages -= 0x20;
+
+    /* XXX: Unlikely to be true, but matches previous behaviour. :( */
+    v_end = (nr_pages + 0x20) << PAGE_SHIFT;
 
     DPRINTF("xc_hvm_restore:dom=%d, nr_pages=0x%lx, store_evtchn=%d, "
             "*store_mfn=%ld, pae=%u, apic=%u.\n", 
@@ -146,7 +149,7 @@ int xc_hvm_restore(int xc_handle, int io_fd,
         0, 0, &pfns[0x00]);
     if ( (rc == 0) && (nr_pages > 0xc0) )
         rc = xc_domain_memory_populate_physmap(
-            xc_handle, dom, nr_pages - 0xc0, 0, 0, &pfns[0xc0]);
+            xc_handle, dom, nr_pages - 0xa0, 0, 0, &pfns[0xc0]);
     if ( rc != 0 )
     {
         PERROR("Could not allocate memory for HVM guest.\n");
@@ -276,14 +279,6 @@ int xc_hvm_restore(int xc_handle, int io_fd,
     else
         shared_page_nr = (v_end >> PAGE_SHIFT) - 1;
 
-    /* Paranoia: clean pages. */
-    if ( xc_clear_domain_page(xc_handle, dom, shared_page_nr) ||
-         xc_clear_domain_page(xc_handle, dom, shared_page_nr-1) ||
-         xc_clear_domain_page(xc_handle, dom, shared_page_nr-2) ) {
-        ERROR("error clearing comms frames!\n");
-        goto out;
-    }
-
     xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, shared_page_nr-1);
     xc_set_hvm_param(xc_handle, dom, HVM_PARAM_BUFIOREQ_PFN, shared_page_nr-2);
     xc_set_hvm_param(xc_handle, dom, HVM_PARAM_IOREQ_PFN, shared_page_nr);
index 39821880160ac916d9befcda1b31160b8f67399b..4b22ecc04fbcf264b9cf67fc5c2ad3adde37c511 100644 (file)
@@ -192,13 +192,11 @@ def restore(xd, fd, dominfo = None, paused = False):
     image_cfg = dominfo.info.get('image', {})
     is_hvm = dominfo.info.is_hvm()
     if is_hvm:
-        hvm  = dominfo.info['memory_static_min']
         apic = int(dominfo.info['platform'].get('apic', 0))
         pae  = int(dominfo.info['platform'].get('pae',  0))
-        log.info("restore hvm domain %d, mem=%d, apic=%d, pae=%d",
-                 dominfo.domid, hvm, apic, pae)
+        log.info("restore hvm domain %d, apic=%d, pae=%d",
+                 dominfo.domid, apic, pae)
     else:
-        hvm  = 0
         apic = 0
         pae  = 0
 
@@ -224,7 +222,7 @@ def restore(xd, fd, dominfo = None, paused = False):
 
         cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE),
                         fd, dominfo.getDomid(), max_pfn,
-                        store_port, console_port, hvm, pae, apic])
+                        store_port, console_port, int(is_hvm), pae, apic])
         log.debug("[xc_restore]: %s", string.join(cmd))
 
         handler = RestoreInputHandler()
index 0eaf3210a3e15ee05bdfd35444ea438f43a9fe1b..a2cf9c115f65738e66a52f2c58fc33b1395ef64d 100644 (file)
@@ -42,8 +42,6 @@ main(int argc, char **argv)
     apic = atoi(argv[8]);
 
     if (hvm) {
-         /* pass the memsize to xc_hvm_restore to find the store_mfn */
-        store_mfn = hvm;
         ret = xc_hvm_restore(xc_fd, io_fd, domid, max_pfn, store_evtchn,
                 &store_mfn, pae, apic);
     } else